package qmsz.api.service.impl;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import qmsz.api.service.WYZSPlatformService;
import qmsz.api.service.traits.TWebPost;
import qmsz.api.utils.QMSZUtils;

@Service
public class WYZSPlatformServiceImpl implements WYZSPlatformService, TWebPost {
	
	@Value("${wyzs.chargev1}")
	private String chargev1URL;
	
	@Value("${qmsz.migu.appkey}")
	private String miguAppkey;
	
	@Value("${qmsz.migu.appsec}")
	private String miguAppsec;
	
	@Override
	public JSONObject chargev1(String cardNo, String cardPwd, String orderNum, String account, String agencyCode, String appkey) {
		JSONObject requestBody = new JSONObject();
		requestBody.put("cardno", cardNo);
		requestBody.put("cardpwd", cardPwd);
		requestBody.put("ordernum", orderNum);
		requestBody.put("account", account);
		requestBody.put("agencycode", agencyCode);
		QMSZUtils.insertTimestamp(requestBody);
		QMSZUtils.WYZSSignGenerator(requestBody, appkey);
		return postURL(requestBody, chargev1URL);
	}
}
